﻿<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="ProductPromotion.aspx.cs" Inherits="ProductPromotion" %>

<%@ Register Src="usercontrols/UniqueProduct.ascx" TagName="UniqueProduct" TagPrefix="uc1" %>
<%@ Register Src="usercontrols/NewsInDay.ascx" TagName="NewsInDay" TagPrefix="uc2" %>
<%@ Register Src="usercontrols/Servey.ascx" TagName="Servey" TagPrefix="uc3" %>
<%@ Register src="usercontrols/Search.ascx" tagname="Search" tagprefix="uc4" %>
<%@ Register src="usercontrols/SiteAds.ascx" tagname="SiteAds" tagprefix="uc5" %>

<asp:Content ID="Content1" ContentPlaceHolderID="headMeta" runat="Server">
    <asp:Literal ID='lblMeta' runat="server" />
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="head" runat="Server">
    <title>
        <asp:Literal ID='lblPageTitle' runat="server" /></title>
        <script>var cpage = 1; var pageCount = 0;</script>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
    <div class='page_body page_width'>
        <div class="TimKiemSlideSiteAds">
            <uc4:Search ID="Search1" runat="server" />
            <div class="SlideShowBlock">
                <div id="wrapper">
                    <a href="http://dev7studios.com" id="dev7link" style="display: none;" title="">
                        </a>
                    <div class="slider-wrapper theme-default">
                        <div class="ribbon">
                        </div>
                        <div id="sliderlist" class="nivoSlider">
                        </div>
                    </div>
                </div>
                <script>
                    $(document).ready(function () {
                        createSlideShow(2, '#sliderlist', '');
                        $('#lblPriceLessThan50').click(function () {
                            fromPrice = 0; toPrice = 50000;
                            loadPromotion();
                            setFilterOptionActive('#lblPriceLessThan50');
                        });
                        $('#lblPriceF50To200').click(function () {
                            fromPrice = 50000; toPrice = 200000;
                            loadPromotion();
                            setFilterOptionActive('#lblPriceF50To200');
                        });
                        $('#lblPriceF200To500').click(function () {
                            fromPrice = 200000; toPrice = 500000;
                            loadPromotion();
                            setFilterOptionActive('#lblPriceF200To500');
                        });
                        $('#lblPriceGreaterThan500').click(function () {
                            fromPrice = 500000; toPrice = 100000000;
                            loadPromotion();
                            setFilterOptionActive('#lblPriceGreaterThan500');
                        });
                        $('#lblPriceAll').click(function () {
                            fromPrice = 0; toPrice = 100000000;
                            loadPromotion();
                            setFilterOptionActive('#lblPriceAll');
                        });

                        
                    });
                </script>
            </div>
            <uc5:SiteAds ID="SiteAds1" runat="server" />
        </div>
        <div id="bodyHolder" class="DanhMucSanPhamList">
            <div id="CategoryMenu" class="LeftCatogory">
                <div class="DanhMucSanPhamHeader">
                    <a id='productcategory'></a>
                </div>
                <div id="leftPanel">
                </div>
                <uc1:UniqueProduct ID="UniqueProduct1" runat="server" />
                <uc2:NewsInDay ID="NewsInDay1" runat="server" />
                <uc3:Servey ID="Servey1" runat="server" />
            </div>
            <div class="KhuyenMaiHangMoiVe">
                <h1>
                    <div class='FilterByPrice'>
                        <div id="lblFilterByPrice" ></div>
                        <div class='FilterOption'>
                            <a id='lblPriceLessThan50'></a>
                            <a id='lblPriceF50To200'></a>
                            <a id='lblPriceF200To500'></a>
                            <a id='lblPriceGreaterThan500'></a>
                            <a id='lblPriceAll' class='active'></a>
                        </div>
                    </div>
                    
                    
                    <asp:Literal ID='ltrPromotionType' Text="category name binding" runat="server" />
                    
                </h1>
                <style>
                    .PromotionTitle.Topical{width: 572px;background-position: -610px -270px;padding-left:105px; background-color: #f7941e}
                    .PromotionTitle{ clear:both; background-position: -610px -192px; width: 642px; padding-left:35px;background-image: url('imgs/Big-bg.jpg'); display:block;  height:72px; line-height:68px; font-size:16px; font-weight:bold; color:White; background-repeat: no-repeat; background-color:#9c1e1e;}
                    .PromotionInfo{float: right;height: 55px;width: 350px;display: block;font-size: 12px;line-height: 17px;padding-top: 17px;font-weight: normal;}
                    .PromotionTitle span{float:left; width:290px; height:72px; display:block;}
                    .PromotionTitle.Topical span{width:220px;}
                    .btnSeeMore{float:right; width:104px; height:20px; display:block; margin-right:25px; background-image: url('imgs/Big-bg.jpg');background-position: -340px -80px; text-align:center; color:#4b4c4b; font-size:10px; }
                </style>
                <div style="display: block; margin-left: 0px; margin-top:10px;">
                    <%--<div id='promotion001'>
                        <div class="PromotionTitle Topical">
                            <div class="PromotionInfo">
                                Thoi gian: tu ngayf 99/99/9999 den 00/00/0000
                                <br />
                                Dieu kien: .......................................
                            </div>
                            <span>San pham chuyen de</span>
                        </div>
                        <div>
                            items...
                        </div>
                        <div class="clear">
                            <a class='btnSeeMore'>xem them</a>
                        </div>
                    </div>--%>
                    <div id='PromotionList'></div>
                    <asp:Literal id='ltrInitScript' runat="server" />
                    <script>
                        function loadPromotion() {
                            totalPromotionVisible=0;
                            totalPromotion = 0;
                            $('#PromotionList').html('');
                            getjsonList("services/WebService.asmx/PromotionsGet",
                                     '{Lang:"' + lang + '", Take:4, Skip:0}',
                                     "PromotionsGet");

                            getjsonList("services/WebService.asmx/PromotionsCount", "", "PromotionsCount");
                            $('#btnMorePromotionPage').click(function () {
                                getjsonList("services/WebService.asmx/PromotionsGet",
                                     '{Lang:"' + lang + '", Take:4, Skip:' + totalPromotionVisible + '}',
                                     "PromotionsGet");
                            });
                        }
                        var totalPromotionVisible = 0;
                        var totalPromotion = 0;
                        $(document).ready(function () {
                            loadPromotion();
                        });

                        function PromotionsGet(data) {

                            totalPromotionVisible += 4;
                            if (totalPromotion != 0 && totalPromotionVisible >= totalPromotion) {
                                $('#btnMorePromotionPage').html(lang_NoMore);
                            }

                            var c = data;
                            if (c != null) {
                                for (var i = 0; i < c.length; i++) {
                                    var item = "";
                                    var localPromotionID = c[i].PromotionID;
                                    if (c[i].PromotionID == 1)
                                        item = "<div id='promotion" + localPromotionID + "'><div class='PromotionTitle Topical'><div class='PromotionInfo'>"
                                    else
                                        item = "<div id='promotion" + localPromotionID + "'><div class='PromotionTitle'><div class='PromotionInfo'>"

                                    item += lang_Time + ": " + lang_FromDate + " " + c[i].StartDate + " " + lang_ToDate + " " + c[i].EndDate + "<br />"
                                                + c[i].PromotionSummary
                                                + "</div><span>" + c[i].PromotionName + "</span></div><div id='promotionItems" + c[i].PromotionID + "'>"


                                    item += "</div><div class='clear' ><a id='btnSeeMorePromotion" + c[i].PromotionID + "' class='btnSeeMore' PromotionID='" + c[i].PromotionID + "' pageindex='1' itemcount='0' ></a></div></div>";
                                    $('#PromotionList').append(item);
                                    getjson("services/WebService.asmx/PromotionGetProducts", '#promotionItems' + c[i].PromotionID, '{pPromotionID:' + c[i].PromotionID + ', Lang: "' + lang + '", Take:' + 4 + ', Skip:' + 0 + ', FromPrice:' + fromPrice + ', ToPrice:' + toPrice + ' }');

                                }
                                $('.btnSeeMore').html('Xem thêm');
                                $('.btnSeeMore').click(function () {
                                    var pageindexInPromotion = parseInt($(this).attr('pageindex'));
                                    var PromotionIDinPromotion = $(this).attr('PromotionID');
                                    var countItemInPromotion = parseInt($(this).attr('itemcount'));
                                    if (countItemInPromotion == 0) {
                                        $.ajax({
                                            type: "POST",
                                            contentType: "application/json; charset=utf-8",
                                            url: "services/WebService.asmx/PromotionProductsCount",
                                            data: '{pPromotionID:' + PromotionIDinPromotion + ', Lang: "' + lang + '", FromPrice:' + fromPrice + ', ToPrice:' + toPrice + ' }',
                                            dataType: "json",
                                            success: function (msg) {
                                                $('#btnSeeMorePromotion' + PromotionIDinPromotion).attr('itemcount', eval(msg.d));
                                                if ((eval(msg.d) / 4) <= 2) {
                                                    $('#btnSeeMorePromotion' + PromotionIDinPromotion).html(lang_NoMore);
                                                }
                                            }
                                        });
                                    }

                                    getjson("services/WebService.asmx/PromotionGetProducts", '#promotionItems' + PromotionIDinPromotion,
                                     '{pPromotionID:' + PromotionIDinPromotion + ', Lang: "' + lang + '", Take:' + 4 + ', Skip:' + (pageindexInPromotion * 4) + ', FromPrice:' + fromPrice + ', ToPrice:' + toPrice + ' }');
                                    pageindexInPromotion += 1;
                                    $(this).attr('pageindex', pageindexInPromotion);
                                    if ((pageindexInPromotion * 4) >= countItemInPromotion && countItemInPromotion != 0) {
                                        $(this).html(lang_NoMore);
                                    }

                                    //alert('{pPromotionID:' + PromotionIDinPromotion + ', Lang: "' + lang + '", Take:' + 4 + ', Skip:' + (pageindexInPromotion * 4) + ', FromPrice:' + fromPrice + ', ToPrice:' + toPrice + ' }');
                                });
                            }
                            if (c == null) {
                                alert('getComment null');
                            }
                        }
                    </script>




                    <div class="pagerControl">
                            <span id='lblPagging'></span>
                            <input class="gotoPage validateNum" id='txtGoToPage' type="text" maxlength="0" />
                    </div>
                    <div class="pagging">
                        <a class="btnLoadMore" id='btnMorePromotionPage' ></a>
                    </div>
                </div>
            </div>
            <div class="clear">
            </div>
        </div>
    </div>
</asp:Content>

